package emulator.unittest.hardware.nmos6502.commands;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import emulator.EmulatorException;
import emulator.hardware.HwByte;
import emulator.hardware.clock.ClockImplementation;
import emulator.hardware.memory.MemoryBlock;
import emulator.hardware.nmos6502.Cpu6502;
import emulator.hardware.nmos6502.Flags6502;
import emulator.hardware.nmos6502.commands.PLP;
import emulator.hardware.nmos6502.operands.NoOperand;

public class PLPTest {

	@Test
	public void testExecute() throws EmulatorException {
		Cpu6502 cpu = new Cpu6502();
		MemoryBlock memory = new MemoryBlock(65536);
		ClockImplementation clock = new ClockImplementation();
		cpu.attach(memory, clock);
		cpu.setSP(new HwByte(0xFE));
		memory.write(0x1FF, 0x55);
		cpu.setFlags(new Flags6502(0xAA));

		PLP plp = new PLP();
		plp.execute(cpu, new NoOperand());
		assertEquals(new HwByte(0xFF), cpu.getSP());
		assertEquals(new HwByte(0x55), cpu.getFlags());
	}
}
